﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace BE.Web.Betfair.Interface.Entities
{
    /// <summary>
    /// 
    /// </summary>
    public sealed class BetMarketPrice
    {
        /// <summary>
        /// 
        /// </summary>
        public enum BetMarketStatus
        {
            /// <summary>
            /// Market is open and available for betting.
            /// </summary>
            Active,
            /// <summary>
            /// Market is finalised, bets to be settled.
            /// </summary>
            Closed,
            /// <summary>
            /// Market is not yet available for betting.
            /// </summary>
            Inactive,
            /// <summary>
            /// Market is temporarily closed for betting, possibly due to pending action such as a goal scored during an in-play match or removing runners from a race.
            /// </summary>
            Suspended,
        }

        /// <summary>
        /// Indicates wether Betfair Starting price is supported
        /// </summary>
        /// <remarks>If true, indicates that the market supports Betfair Starting Price bets.</remarks>
        public bool IsBSPSupported { get; private set; }

        /// <summary>
        /// Three letter ISO 4217 code
        /// </summary>
        public string IsoCurrencyCode { get; private set; }

        /// <summary>
        /// Id of the market
        /// </summary>
        public int MarketId { get; private set; }

        /// <summary>
        /// BetDelay in Seconds
        /// </summary>
        /// <remarks>The number of seconds delay between submission and a bet actually getting placed. This is greater than 0 if and only if the market is in-play.</remarks>
        public int Delay { get; private set; }

        /// <summary>
        /// Indicates wether Discounts will be applyed
        /// </summary>
        /// <remarks>Indicates whether or not the user’s discount rate is taken into account on this market. If ‘false’ all users will be charged the same commission rate, regardless of discount rate.</remarks>
        public bool IsDiscountAllowed { get; private set; }

        /// <summary>
        /// Default markt reate
        /// </summary>
        /// <remarks>This will indicate the commission price set for each market.</remarks>
        public float MarketBaseRate { get; private set; }

        /// <summary>
        /// Informations about the market
        /// </summary>
        /// <remarks>The text associated with the market containing market specific information and rules. This part of the text contains dynamic information such as non-runners</remarks>
        public string MarketInfo { get; private set; }

        /// <summary>
        /// MarketStatus
        /// </summary>
        public BetMarketStatus MarketStatus { get; private set; }

        /// <summary>
        /// How many winners there are in this market (e.g. 1 for win markets, but 2,3 or 4 for place markets)
        /// </summary>
        public int NumberOfWinners { get; private set; }

        /// <summary>
        /// Runner Prices
        /// </summary>
        public ReadOnlyCollection<BetRunnerPrice> RunnerPrices { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BetMarketPrice"/> class.
        /// </summary>
        /// <param name="marketId">The market id.</param>
        /// <param name="isBSPSupported">if set to <c>true</c> [is BSP supported].</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <param name="delay">The delay.</param>
        /// <param name="discount">if set to <c>true</c> [discount].</param>
        /// <param name="marketbase">The marketbase.</param>
        /// <param name="marketInfo">The market info.</param>
        /// <param name="status">The status.</param>
        /// <param name="numberOfWinners">The number of winners.</param>
        /// <param name="prices">The prices.</param>
        public BetMarketPrice(int marketId, bool isBSPSupported, string currencyCode, int delay, bool discount, float marketbase, string marketInfo, BetMarketStatus status, int numberOfWinners,IEnumerable<BetRunnerPrice> prices)
        {
            this.IsBSPSupported = isBSPSupported;
            this.MarketId = marketId;
            this.IsoCurrencyCode = IsoCurrencyCode;
            this.Delay = delay;
            this.IsDiscountAllowed= discount;
            this.MarketBaseRate = marketbase;
            this.MarketInfo = marketInfo;
            this.MarketStatus = status;
            this.NumberOfWinners = numberOfWinners;


        }
    }
}
